#ifndef LEETCODE_CN_CPP_JIANZHI_5_H
#define LEETCODE_CN_CPP_JIANZHI_5_H

#include <algorithm>
#include <string>

using namespace std;

namespace jianzhi_5
{

class Solution
{
public:
    string replaceSpace(string s)
    {
        int spaceCount = count(s.begin(), s.end(), ' ');
        string res;
        res.reserve(s.size() + spaceCount * 2);
        for (auto c : s)
        {
            if (c == ' ')
            {
                res += "\%20";
            }
            else
            {
                res += c;
            }
        }
        return move(res);
    }
};

} // namespace jianzhi_5

#endif //LEETCODE_CN_CPP_JIANZHI_5_H
